package sample.plugin.html.project;

import com.rapid.api.component.widget.tree.TreeItemViewHolder;
import com.rapid.api.ext.plugin.AndroidPlugins;
import com.rapid.api.framework.project.file.ProjectFileUiEvent;
import com.rapid.api.project.DefaultProjectFileManager;
import com.rapid.api.project.structure.PSObject;
import com.rapid.api.project.structure.TreeNode;
import com.rapid.util.android.ContextUtils;

import sample.plugin.html.R;

public class HtmlFileManager extends DefaultProjectFileManager<HtmlProject>
        implements ProjectFileUiEvent {
    @Override
    public void onBindView(TreeItemViewHolder holder, TreeNode<PSObject> node) {
        String name = node.getSource().getName();
        if (name.endsWith(".html") || name.endsWith(".htm") || name.endsWith(".xhtml")) {
            holder.loadIcon(
                    ContextUtils.getDrawable(
                            AndroidPlugins.getContext(this),
                            R.drawable.ic_file_html
                    )
            );
        }
    }
}
